/**
 * Created by mooshroom on 2015/5/20 0020.
 */
define('list', function () {
    return list = avalon.define({
        $id: "list",
        url: "./package/list/list.html",
        ready: function (cid) {
            list.List=[]
            list.Page=1
            list.ClassID=""
            list.Get()
        },

        thisUID:cache.go('uid'),
        //获取文章列表主函数
        List: [],
        Get: function (data) {
            var d=data||{}
            var ClassID = d.ClassID || "",
                AuthorUID = d.AuthorUID|| '',
                Status = d.Status|| '',
                Page = d.Page || 1,
                PageNumber = d.PageNumber || 12;

            $.call({
                type: "post",
                i: "GetArticleList",
                data: {
                    ClassID: ClassID,
                    AuthorUID:AuthorUID,
//                    Status:Status,
                    Page: Page,
                    PageNumber: PageNumber
                },
                success: function (data) {
                    if (data.c == 200) {
                        list.Page=Page
                        list.ClassID=ClassID
                        if (data.d.List.length > 0) {
                            for(var i=0;i<data.d.List.length;i++){
                                list.List.push(data.d.List[i])
                            }

                        }
                    }
                }
            })
        },

        //搜索
        search:function(key){
            $.call({
                type:"post",
                i:"CMSSearch",
                data:{
                    keyword:key
                },
                success:function(res){
                    if(res.c==200){
                        list.List=res.d
                    }
                }
            })
        },

        //获取更多
        Page:1,
        ClassID:"",
        getMore:function(){
            list.Get({
                ClassID:list.ClassID,
                Page:list.Page+1
            })
        }


    })
})
